﻿using System;
using Sanelib.Common.Extensions;
using Sanelib.Common.Helpers;
using Sanelib.Dto;

namespace Common.Commands.MemberCommands
{
    public class UpdateMemberNotification : AuditedCommand
    {
        public string Email { get; set; }
        public string Mobile { get; set; }
        public bool SendEmail { get; set; }
        public bool SendSms { get; set; }
        public bool UsePrint { get; set; }
        public bool Block { get; set; }

        public override Guid? GetAggregateId()
        {
            return null;
        }

        public override ErrorResult Validate()
        {
            var validationResult = new ErrorResult();

            if (!string.IsNullOrWhiteSpace(Email) && Email.Length > 64)
                validationResult.AddError("Email", " entered exceeds the maximum length 128");

            if (Email.IsEmpty())
            {
                validationResult.AddError("Email", "should not be empty");
            }
            else if (Formatter.EmailId(Email) != true)
            {
                validationResult.AddError("Email", "should be correct formate. (xxxxx@xxx.xx)");
            }

            if (!string.IsNullOrWhiteSpace(Mobile) && Mobile.Length > 32)
                validationResult.AddError("Mobile", " entered exceeds the maximum length 32");

            if (string.IsNullOrWhiteSpace(Mobile))
                validationResult.AddError("Mobile number ", "should not be empty.");
           
            return validationResult;
        }
    }
}
